package com.spn.blog.api.controller.article;

import com.spn.blog.common.vo.Result;
import com.spn.blog.service.article.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "标签模块")
@RestController
@RequestMapping("api/tags")
public class TagsController {

    @DubboReference
    private TagService tagService;

//    @PostMapping()
//    public Result test(){
//        return Result.success(null);
//    }

    @ApiOperation(value = "获取 - 最热标签")
    @GetMapping("hot")
    public Result hot() {
        //查询最热门的6个标签
        int limit = 6;
        return tagService.hots(limit);
    }

    @ApiOperation(value = "获取 - 所有标签")
    @GetMapping
    public Result findAll() {
        return tagService.findAll();
    }

    @ApiOperation(value = "获取 - 所有标签详细内容")
    @GetMapping("detail")
    public Result findAllDetail() {
        return tagService.findAllDetail();
    }

    @ApiOperation(value = "获取 - 单个标签所有内容")
    @GetMapping("detail/{id}")
    public Result findAllDetailById(@PathVariable("id") Long id) {
        return tagService.findAllDetailById(id);
    }
}
